package scanningModule;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import javax.swing.JDialog;
import javax.swing.JFrame;

import main.Application;

import com.adobe.acrobat.Viewer;

import exception.PDFVewerException;



public class pdfViewer extends JDialog
{
	
	Viewer viewer;
	InputStream input;
	static private final long serialVersionUID = 1L; 
	
	public pdfViewer(JFrame parent, String frameName,Dialog.ModalityType cos,String fileName, int width,int height) throws FileNotFoundException, PDFVewerException
	{
		super(parent,frameName,cos);
		try
		{	
			viewer = new Viewer(false);			
			add(viewer, BorderLayout.CENTER);
			input = new FileInputStream (new File(fileName));			
			viewer.setDocumentInputStream(input);
			viewer.setProperty("Default_Page_Layout",
	        "SinglePage");
			viewer.setProperty("Default_Zoom_Type",
	        "FitPage");
			viewer.setProperty("Default_Magnification",
	        "100");
			viewer.activate();
		}
		catch(FileNotFoundException e)
		{
			Application.getInstance().notifyAboutException(e);
		}
		catch(Exception e)
		{
			Application.getInstance().notifyAboutException(new PDFVewerException(e));
		}
		     setSize(width, height);
		     setVisible(true);

	}
}
